<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import = "java.util.*" %>
<sql:query var="rs" dataSource="jdbc/QASDB">
    select id, category, template, difflevel from question order by category desc
</sql:query>

<html>
    <head><title>Question Template List</title></head>
 <script type="text/javascript">  
 $(document).ready(function() {
 $("#qtable tr").hover(
		  function () {
			  $(this).addClass('tablehighlight');
		  }, 
		  function () {
		    $(this).removeClass('tablehighlight');
		  }
		);
 });
 
           </script>
    <body bgcolor="white">
        <table  width="100%" border="0">
            <tr>
                <td> 
                    <table  width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td><table id="qtable" width="100%" cellpadding="8" border="1px" bordercolor="#000000" cellspacing="0px" style="border-collapse:collapse">
                                    <tr>
				
					<th colspan="2">Action</th>
					<th>Grade</th>
					<th>Topic</th>
					<th>Difficulty</th>
					<th>Question Template</th>
					
				</tr>
				 
                                    <c:forEach var="row" items="${rs.rows}">
                                     <%
                                            TreeMap row = (TreeMap)pageContext.getAttribute("row");   
                                            Integer cid = Integer.parseInt(String.valueOf(row.get("category")));
                                         
                                            %>
                                        <form action="" method=post>
                                            <tr>
                                                <td style="text-align: right;"><input name="button" type="submit" value="Edit"></td>
                                                <td style="text-align: right;"><input name="button" type="submit" value="Delete" onClick="return confirm('Sure? The variable definition, relations, solutions for this question will be Deleted!')"></td>
                                            <input name="act" type="hidden">
                                            <input name="myid" type="hidden" value=${row.id}> 
                                           <% %>
                                           <td><%=n.getCategory(cid).getGrade() %></td>
                                           <td><%=n.getCategory(cid).getTopic() %></td>
                                            <td><%=n.getDifficultyLevelName((Integer)row.get("diffLevel"))%></td>
                                            <td width="100%">[<b>Template</b>]--${row.template}</td>
                                            </tr>
                                        </form><p>
                                        </c:forEach> 
                                </table></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>



        </font>
    </body>
</html>

